<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>v-show指令</title>
</head>
<body>
<div id="app">
    <h2>年齡：{{age}}</h2>
    <p>age>18显示海盗</p>
    <input type="button" value="累加年龄" @click="addAge">
    <input type="button" value="切换显示状态" @click="changeIsShow">
    <img v-show="isShow" src="./img/Cat.jpg" alt="🐱">
    <img v-show="age>18" src="./img/pirate.jpg" alt="海盜">
</div>

<!-- 生产环境版本，优化了尺寸和速度 -->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script type="text/javascript">
    var vue = new Vue({
        el: "#app",
        data: {
            isShow: false,
            age: 17
        },
        methods: {
            changeIsShow: function () {
                this.isShow = !this.isShow;
            },
            addAge: function () {
                this.age++;
            }
        }
    })
</script>
</body>
</html>
